\documentclass[twoside,10pt,AutoFakeBold,AutoFakeSlant]{book}

\usepackage{xeCJK}
\usepackage{indentfirst}
\usepackage{minted}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{enumitem}
\usepackage{framed}
\usepackage[colorlinks,breaklinks,linktoc=page,allcolors=linkcolor]{hyperref}
\usepackage[numbered]{bookmark}     % 设置书签
\usepackage[pagestyles,clearempty]{titlesec}   % 设置页眉格式
\usepackage[a4paper,left=2cm,right=2cm,bottom=3.67cm]{geometry} % 设置页边距
\usepackage{pifont}     % 带圈数字

\linespread{1.25}\linespread{1.4}   % 设置行距
\CJKsetecglue{\,}                   % 设置中英文间的空格

\setminted{fontsize=\small}  % 设置代码字体大小
\usemintedstyle{solarized-light}    % 设置代码环境高亮主题

% 取消中文字体设置，因为只有windows才有宋体和楷体这两个字体
% \setCJKmainfont[ItalicFont=楷体,BoldItalicFont=楷体]{宋体}  % 设置中文正文字体
% \setCJKmonofont{宋体}                                       % 设置中文等宽字体

% \setmainfont{Times New Roman}                               % 设置英文正文字体
\setmonofont[Path=../fonts/,BoldFont=Inconsolata-Bold.ttf]{Inconsolata-Regular.ttf}       % 设置英文等宽字体
\setlist{nosep}                 % 设置列表垂直间距为0

\newpagestyle{front}{               % 自定义页眉格式
\sethead[\thepage][][\chaptertitle] % 偶数页页眉格式
{\chaptertitle}{}{\thepage}         % 奇数页页眉格式
\headrule                           % 页眉下水平分隔线
}

\newpagestyle{main}{        % 自定义页眉格式
\sethead[\thepage][][Chapter \thechapter: \quad \chaptertitle] % 偶数页页眉格式
{\thesection \quad \sectiontitle}{}{\thepage}   % 奇数页页眉格式
\headrule                   % 页眉下水平分隔线
}

\definecolor{linkcolor}{RGB}{175, 74, 87}       % 定义链接颜色
\definecolor{tablecolor}{RGB}{241, 246, 252}    % 定义表格背景颜色

\renewcommand{\thetable}{\thechapter{}-\arabic{table}}    % 表格编号
\renewcommand{\tablename}{表}
\renewcommand{\tableautorefname}{表}

\renewcommand{\thefigure}{\thechapter{}-\arabic{figure}}  % 图片编号
\renewcommand{\figurename}{图}
\renewcommand{\figureautorefname}{图}

\newenvironment{note}{
    \begin{framed}
        \begin{center}
            {\color{gray} \huge{\textbf{\texttt{N\,O\,T\,E}}}}
        \end{center}
}{
    \end{framed}
}

\newcommand{\codeentry}[1]{
    \begin{flushleft}
        \emph{\texttt{#1}}
    \end{flushleft}
}

\newcommand{\hangparagraph}[1]{
    \hangafter 0
    \hangindent 3em
    \noindent
    #1
}

% \includeonly{ch02.tex}

\usepackage{tikz}

% Document
\begin{document}
  \begin{sloppypar} %latex中一行文字出现溢出问题的解决方法
    %\maketitle

    \begin{center}
      \thispagestyle{empty}
      %\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{cover.jpg}
      \begin{tikzpicture}[remember picture, overlay, inner sep=0pt]
        \node at (current page.center)
        {\includegraphics[width=\paperwidth, keepaspectratio=false]{cover.jpg}};
      \end{tikzpicture}
      \newpage
      \thispagestyle{empty}
      \huge
      \textbf{Programming Rust, 2nd Edition}
      \\[10pt]
      \normalsize
      Fast, Safe Systems Development
      \\[9pt]
      \normalsize
      作者: Jim Blandy, Jason Orendorff, Leonora F. S. Tindall
      \\[8pt]
      \normalsize
      译者：\href{https://github.com/MeouSker77/ProgrammingRust}{MeouSker77}
      \\[8pt]
      \normalsize
      版本：\href{https://www.oreilly.com/library/view/programming-rust-2nd/9781492052586/}{2021-06-11}
    \end{center}

    \frontmatter
    \setcounter{secnumdepth}{0}
    \pagestyle{front}
    \phantomsection
    \pdfbookmark[0]{目录}{\indexname}
    \tableofcontents
    \include{preface}
    \include{translator}

    \mainmatter
    \setcounter{secnumdepth}{2}
    \pagestyle{main}
    \include{ch01}
    \include{ch02}
    \include{ch03}
    \include{ch04}
    \include{ch05}
    \include{ch06}
    \include{ch07}
    \include{ch08}
    \include{ch09}
    \include{ch10}
    \include{ch11}
    \include{ch12}
    \include{ch13}
    \include{ch14}
    \include{ch15}
    \include{ch16}
    \include{ch17}
    \include{ch18}
    \include{ch19}
    \include{ch20}
    \include{ch21}
    \include{ch22}
    \include{ch23}
    \backmatter
  \end{sloppypar}
\end{document}
